package com.hspedu.tankgame3;

/**
 * @author LiuJinTao
 * @className Tank
 * @date 2024/06/20 17:35
 * @description TODO
 */
public class Tank {
    private int x;// 坦克的横坐标
    private int y;// 坦克的纵坐标
    private int direct;// 坦克的方向
    private int speed = 3;// 速度

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    // 上右下左移动
    public void moveUp() {
        if (y >= speed) y -= speed;
        else y = 0;
    }

    public void moveRight() {
        if (x <= (1000-speed-60)) x += speed;
        else x = 940;
    }

    public void moveDown() {
        if (y <= (750-speed-60)) y += speed;
        else y = 690;
    }

    public void moveLeft() {
        if (x >= 0) x -= speed;
        else x = 0;
    }

    public int getDirect() {
        return direct;
    }

    public void setDirect(int direct) {
        this.direct = direct;
    }

    public Tank(int x, int y, int direct) {
        this.x = x;
        this.y = y;
        this.direct = direct;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}
